package com.thread;

import org.junit.Test;

/**
 * Created by Sunny on 2016/4/4.
 */
public class ThreadTest2 extends Thread{

    @Override
    public void run() {
        System.out.println("运行");
        super.run();
    }

    /**
     * 运行报错：
     * java.lang.IllegalThreadStateException
     at java.lang.Thread.start(Thread.java:705)
     at com.thread.ThreadTest2.testDuplicateOneThread(ThreadTest2.java:20)
     查看抛出错误的源代码：
         if (threadStatus != 0)
         throw new IllegalThreadStateException();
     发现线程状态并非为0

     网上解答：如果在一个死去的线程上调用start()方法，会抛出java.lang.IllegalThreadStateException异常
     */
    @Test
    public void testDuplicateOneThread(){
        ThreadTest2 test1 = new ThreadTest2();
        test1.start();
        test1.start();
        test1.start();
        test1.start();
        test1.start();
        test1.start();

    }
}
